#define _CRT_SECURE_NO_WARNINGS 1
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'

ll digit_sum(ll x) {
	ll a[10] = { 6,2,5,5,4,5,6,3,7,6 };
	ll res = 0;
	while (x) {
		res += a[x % 10];
		x /= 10;
	}
	return res;
}

void solve() {
	ll l, r; cin >> l >> r;
	if (r - l >= 11) {
		cout << 2 << endl;
		return;
	}
	for (ll i = l; i < r; i++) {
		if (digit_sum(i) == digit_sum(i + 1)) {
			cout << 2 << endl;
			return;
		}
	}
	cout << 1 << endl;
}

int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	solve();
	return 0;
}